package myview;//package io.dcloud.H5C262A3E.network.networkutils;

import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.Window;
import android.widget.FrameLayout;

import androidx.annotation.NonNull;

import com.bigchun.woodhunter.R;
import com.wang.avi.AVLoadingIndicatorView;


/**
 * Author: John
 * E-mail: 634930172@qq.com
 * Date: 2018/1/10 0010 14:31
 * <p/>
 * Description:加载的Dialog
 */

public class LoadingDialog extends Dialog {


    //    @BindView(R.id.loading)
    private AVLoadingIndicatorView loading;
    //    private TextView loading_text;
    private String loadingMsg;

    public LoadingDialog(@NonNull Context context) {
        this(context, R.style.loading_style);
    }

    private LoadingDialog(@NonNull Context context, int themeResId) {
        super(context, themeResId);
    }

    public LoadingDialog(@NonNull Context context, String loadingMsg) {
        this(context, R.style.loading_style);
        this.loadingMsg = loadingMsg;
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.dialog_loading);
        setCanceledOnTouchOutside(true);
        initView();
        initData();
    }



    private void initData() {
        if (!TextUtils.isEmpty(loadingMsg)) {
//            loading_text.setText(loadingMsg);
        }

    }

    private void initView() {
        loading = findViewById(R.id.loading);
//        loading_text=findViewById(R.id.loading_text);
    }

    @Override
    public void show() {
        super.show();
        loading.show();
    }

    @Override
    public void dismiss() {
//        InputMethodManager inputMgr = (InputMethodManager) getContext()
//                .getSystemService(Context.INPUT_METHOD_SERVICE);
//        inputMgr.toggleSoftInput(InputMethodManager.HIDE_NOT_ALWAYS, 0);
        super.dismiss();
    }
}
